import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/Login',//路由 
    name: 'Login',//名称 
    component: () => import('../views/Login.vue')//页面 
  },
  {
    path: '/Home',
    name: 'Home',
    component: () => import('../views/Home.vue'),
    redirect: '/Admin',//默认加载页面 Admin.vue 
    children: [
      //其他需要在Home页面显示的子页面 
      {
        path: '/Admin',
        name: 'Admin',
        component: () => import('../views/Admin.vue'),
        meta:{ role:'超级管理员' }
      }, {
        path: '/Order',
        name: 'Order',
        component: () => import('../views/Order.vue')
      }, {
        path: '/Total',
        name: 'Total',
        component: () => import('../views/Total')
      }, {//编辑管理员 
        path: '/AdminEdit',
        name: 'AdminEdit',
        component: () => import('../views/EditAdmin')
      }, {
        path: '/OrderView',
        name: 'OrderView',
        component: () => import('../views/OrderView')
      },{ 
        path:'*', 
        component:()=>import('../views/NotFound') 
      }]
  }



]
// 解决重复点击相同路由报错 Error: Avoided redundant navigation to current location: 
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) }
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


export default router
